package com.pti.usermanager.dao.impl;

import com.pti.usermanager.dao.api.RoleDao;
import com.pti.usermanager.dao.mapper.RoleMapper;
import com.pti.usermanager.dao.po.RolePo;
import com.pti.usermanager.web.dto.request.SaveRoleRequest;
import com.pti.usermanager.web.dto.request.UpdateRoleRequest;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @ClassName: RoleDaoImpl
 * @Author: mahuilin
 * @Description: 角色数据交换实现层
 * @Date: 2019/1/17
 */
@Repository
public class RoleDaoImpl implements RoleDao {

    private static final Logger logger = LogManager.getLogger(RoleDaoImpl.class);

    @Autowired
    private RoleMapper roleMapper;


    @Override
    public List<RolePo> findAll(String roleNm) {
        return roleMapper.findAll(roleNm);
    }

    @Override
    public RolePo findAllByRoleId(Long roleId) {
        return roleMapper.findAllByRoleId(roleId);
    }

    @Override
    public void saveRole(SaveRoleRequest saveRoleRequest) {
        roleMapper.saveRole(saveRoleRequest);
    }

    @Override
    public void updateRole(UpdateRoleRequest updateRoleRequest) {
        roleMapper.updateRole(updateRoleRequest);
    }

    @Override
    public void delRole(Long roleId) {
        roleMapper.delRole(roleId);
    }

    @Override
    public void saveUserByRidAndUid(Long roleId, Long usrId) {
        roleMapper.saveUserByRidAndUid(roleId, usrId);
    }

    @Override
    public void deleteUserByRid(Long roleId) {
        roleMapper.deleteUserByRid(roleId);
    }

    @Override
    public void saveMenuByRidAndMid(Long roleId, Long menuId) {
        roleMapper.saveMenuByRidAndMid(roleId, menuId);
    }

    @Override
    public void deleteMenuByRid(Long roleId) {
        roleMapper.deleteMenuByRid(roleId);
    }

}
